package com.example.tetstmybatis.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RedisController2 {
    @Autowired
    private RedisTemplate redisTemplate;
    @GetMapping("/redis/get1/{key}")
    public Object get(@PathVariable("key") String key) {
        return redisTemplate.opsForValue().get(key);
    }

    @PostMapping("/redis/set1/{key}/{value}")
    public Object set(@PathVariable("key") String key,
                      @PathVariable("value") String value) {
        redisTemplate.opsForValue().set(key, value);
        return "set success";
    }
}